const express = require('express')

const app =express()

// 在所有路由前增加，可以拦截所有请求
app.all("*", (req, res, next) => {
  // res.header("Access-Control-Allow-Origin", "http://localhost:8000");
  res.header("Access-Control-Allow-Origin", req.headers.origin);
  res.header("Access-Control-Allow-Credentials", true);
  res.header("Referrer-Policy", 'no-referrer-when-downgrade');
  next();
});

app.get("/app2", (req, res) => {
	console.log('app2', req.headers.cookie)
	res.json({ code: 0, msg: "这是8003端口返回" })
})

app.use("/static", express.static('public'))

app.listen("8003", () => {
	console.log("app2 running at port 8003")
})
